package main
import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	"git.900sui.cn/kc/rpcinterface/client/order"
	"github.com/streadway/amqp"
	"strconv"
)
/**
 * @className pinganThirdOrderTask
 * 执行平安银行第三方在途充值订单
 * @author liyang<654516092@qq.com>
 * @date 2021/4/27 16:24
 */


func main() {
	mOrder := new(order.PingAn).Init()
	defer mOrder.Close()
	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("order.log.pinganThirdOrderTask"))
	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("order.queue.pinganThirdOrderTask"), func(msg amqp.Delivery) {
		paymentId,_:= strconv.Atoi(string(msg.Body))
		var reply bool
		err := mOrder.PayThirdPayment(context.Background(), &paymentId, &reply)
		if err != nil {
			utils.Logerr.Printf("平安银行第三方在途充值-执行充值失败,paymentId:%d, err:%s", paymentId, err)
		}
	})
	if err != nil {
		utils.Logerr.Printf("平安银行第三方在途充值--执行充值失败，err: %s", err.Error())
	}
}

